<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="./css/aui-flex.css">
  <link rel="stylesheet" href="./css/aui-padding.css">
  <link rel="stylesheet" href="./css/aui-margin.css">
  <link rel="stylesheet" href="./css/aui-pc.css">
  <link rel="stylesheet" href="./css/aui-font.css">
  <script src="./js/jquery.min.js"></script>
  <script src="./js/messengers.js"></script>
  <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
  <title></title>
  <style>
    #body {
      height: 100vh;
    }

    #wrap {
      margin: auto;
      width: 500px;
    }

    .aui-but {
      color: #fff;
      background: #247FFF;
      box-shadow: 0rpx 5px 11px 0px rgba(36, 127, 255, 0.31);
      border-radius: 5px;
      line-height: 40px;
      text-align: center;
      cursor: pointer;
    }

    .aui-but.noshadow {
      box-shadow: none
    }

    .aui-but-k {
      color: #376EFF;
      border: 1px solid #376EFF;
      text-align: center;
      border-radius: 5px;
      line-height: 40px;
      cursor: pointer;
    }

    .w-150 {
      width: 150px;
      /* margin: 0 auto; */
    }

    .flieName {
      color: #999;
      width: 400px;
      text-decoration: underline;
      cursor: pointer;
      padding-bottom: 10px;
    }

    .success {
      color: #247FFF;
      text-align: center;
    }
  </style>
</head>

<body id="body" class="aui-flex">

  <div id="wrap">

    <div class="aui-flex">
      <p class="aui-but w-150" id="addFile">重新/选择文件</p>
      <p class="aui-but-k w-150 aui-margin-l-10" id="start">开始转换</p>
    </div>
    <p class="aui-font-size-18 aui-padded-t-20 aui-padded-b-10">已选择的文件</p>
    <div id="flieNameList">

    </div>
  </div>

  <script>
    var filePath = []
    $("#addFile").on('click', function () {
      window.messengers.on('addFile', {
      }, function (res) {
        filePath = res
        if (res) {

          let html = ''
          res.forEach(function (el) {
            html += `
            <div class="aui-flex">
              <p class="flieName">${el}</p>
            </div>
            `
          });
          $('#flieNameList').html(html)
        }

      })
    })

    $("#start").on('click', function () {
      if (!filePath.length) {
        alert('请选择文件')
        return
      }
      window.messengers.on('transform', {}, function (res) {
        let html = ''
        html += `
            <div class="aui-flex">
              <p class="success aui-ellipsis-1">转换成功</p>
            </div>
            `
        $('#flieNameList').html(html)
      })
    })


  </script>

</body>

</html>